#include "widget.h"

#include <QSpinBox>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    resize(600, 480);
    QSpinBox *spinBox = new QSpinBox(this);
    spinBox->move(100, 100);
    spinBox->resize(200, 30);

    //设置范围
    spinBox->setRange(-100, 100);
    //设置默认值
    spinBox->setValue(20);
    //设置每次改变的幅度
    spinBox->setSingleStep(10);

    connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int x){
        qDebug() <<"x = " << x;
        qDebug() << "value = "<<spinBox->value();
    });
}

Widget::~Widget()
{
}

